let id = location.search.slice(4);
let xhr1 = new XMLHttpRequest();
xhr1.open('get', `http://39.105.198.203:3001/prod/det?tid=${id}`);  
xhr1.send();
xhr1.onreadystatechange = function () {
    if (this.readyState === 4 && this.status === 200) { // 确保请求成功
        let res = JSON.parse(this.responseText);
        console.log(res);

        // 创建轮播图的 HTML 元素
        let box = $('<div class="lunboBox"> \
                    <ul class="lunbo"> \
                    <li><img src="' + res.data.imgarr[0] + '"></li> \
                    <li><img src="' + res.data.imgarr[1] + '"></li> \
                    <li><img src="' + res.data.imgarr[2] + '"></li> \
                    </ul> \
                  </div> \
                  <div class="content"> \
                    <div><img class="contentPic" src="' + res.data.fullSrc + '"></div> \
                    <div class="contentBox"> \
                      <div class="content1"> \
                        <p>' + res.data.tname + '</p> \
                        <p>' + res.data.tintro + '</p> \
                      </div> \
                      <p class="content2"> \
                        <span class="text">￥</span> \
                        <span class="text1">' + res.data.price + '</span> \
                        <span class="text">.00</span> \
                      </p> \
                    </div> \
                  </div> \
                  <img class="bigPic" src="' + res.data.banner + '" alt="">');
        $('.xuanran').append(box);

        let index = 0;
        function lunbo() {
            let countingdown = setInterval(function () {
                index++;
                if (index === 3) { index = 0; }
                switching();
            }, 2000);

            $('.lunboBox').hover(function () {
                clearInterval(countingdown);
            }, function () {
                countingdown = setInterval(function () {
                    index++;
                    if (index == 3) { index = 0; }
                    switching();
                }, 2000);
            });
        }

        function switching() {
            $('.lunboBox .lunbo').css('left', -10 * index + 'rem');
        }
        lunbo();
    }
}